package com.gpms.action.paper;

import java.util.Map;

import com.gpms.bean.Student;
import com.gpms.bean.Topics;
import com.gpms.service.Topics.IStudentTopicsOperate;
import com.gpms.service.Topics.TopicsOperateFactory;
import com.gpms.service.file.FileFactory;
import com.gpms.service.file.IFileService;
import com.opensymphony.xwork2.ActionContext;

public class PaperPlatformAction {
	private String fileNum;
	private String title;
	private String content;
	private int topicsID;
	
	public String getFileNum() {
		return fileNum;
	}
	public void setFileNum(String fileNum) {
		this.fileNum = fileNum;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public int getTopicsID() {
		return topicsID;
	}
	public void setTopicsID(int topicsID) {
		this.topicsID = topicsID;
	}

	public String execute() throws Exception
	{
		Student student = getStudent();
		Topics topics = getMytopics(student);
		IFileService fileOperate = FileFactory.createFileServer("file");
		int leftNum = fileOperate.getSubmitNum(topics.getTopicsNum(), 6,3);
		setFileNum(String.valueOf(leftNum));
		setTopicsID(topics.getTopicsNum());
		return "success";
	}

	public Student getStudent(){
		Map session = ActionContext.getContext().getSession();
		Student student = (Student)session.get("user");
		return student;
	}
	public Topics getMytopics(Student student){
		IStudentTopicsOperate operate = (IStudentTopicsOperate)TopicsOperateFactory.createOperate("student");
		Topics topics = operate.showMyTopics(student);
		return topics;
	}
}
